import {
    INCREMENT
} from './mutations-types';

export default {
    // 方法
    [INCREMENT](state){
        state.counter++
    },
    decrement(state){
        state.counter--
    },
    incrementCount(state,count){
        state.counter += count;
    },
    addStu(state,stu){
        state.students.push(stu);
    },
    incrementCount2(state,payload){
        // 传入的就不是count而是一个对象
        console.log(payload);
        state.counter += payload.count;
    },
    updateInfo(state){
        // 添加数据后只在插件中显示,但在视图中不响应
        // state.info['address'] = "nanjing"
        // 响应式添加数据
        Vue.set(state.info,'address2','nanjing2');
    },
    deleteInfo(state){
        // 删除数据后只在插件中显示,但在视图中不响应
        // delete state.info.age;
        // 响应式删除数据
        Vue.delete(state.info,'age');
    },
    updateInfo2(state){
        setTimeout(()=>{
            state.info.name = 'lion123'
        },1000); 
    },
    updateInfo3(state){
            state.info.name = 'lion12345678'
    }
}
  